from common_import import *
from matplotlib.ticker import PercentFormatter


def plot_histogram_sum_直方图():
    data_dict = {0: 3, 1: 709, 2: 630, 3: 444, 4: 177, 5: 11}
    # 分别获取字典的键和值
    keys = list(data_dict.keys())
    values = list(data_dict.values())

    # 绘制直方图
    plt.figure(figsize=(10, 6))
    plt.bar(keys, values, color="blue", edgecolor="black", alpha=0.7)

    plt.title("")
    plt.xlabel("取值")
    plt.ylabel("频数")
    # plt.legend()
    # plt.grid(True)
    # plt.show()
    tool.show_or_print("sum_直方图.png")


def plot_histogram():
    data_dict = {
        "Caco-2": 38.45,
        "CYP3A4": 74.012,
        "Non_hERG": 44.326,
        "HOB": 74.215,
        "Non_MN": 23.303,
    }
    # 分别获取字典的键和值
    keys = list(data_dict.keys())
    values = list(data_dict.values())

    # 绘制直方图
    plt.figure(figsize=(10, 6))
    plt.bar(keys, values, color="blue", edgecolor="black", alpha=0.7)

    # 设置标题和轴标签
    plt.title("")
    plt.xlabel("性质")
    plt.ylabel("优良占比 (%)")

    # 设置y轴为百分比格式
    plt.gca().yaxis.set_major_formatter(PercentFormatter())
    # y轴从0到100%
    plt.ylim(0, 100)
    # plt.legend()
    # plt.grid(True)
    # plt.show()
    tool.show_or_print("性质优良占比直方图.png")


if __name__ == "__main__":
    plot_histogram()
    pass
